/*
Sader engine framework
(c) Rachel J. Morris
MIT License
www.moosader.com
*/

#include "BaseCamera.h"

namespace sader
{

BaseCamera::BaseCamera()
{
    m_RotationSpeed = 5.0f;
    m_TransformSpeed = 5.0f;
    m_xRotation = m_yRotation = m_zRotation = 0.0f;

    m_xTransform = 0.0f;
    m_yTransform = 0.0f;
    m_zTransform = -100.0f;
}

void BaseCamera::Init( float mx, float my, float mz, float rx, float ry, float rz, float s, float rs )
{
    m_xTransform = mx;
    m_yTransform = my;
    m_zTransform = mz;

    m_xRotation = rx;
    m_yRotation = ry;
    m_zRotation = rz;

    m_TransformSpeed = s;
    m_RotationSpeed = rs;
}

void BaseCamera::Prep()
{
      // Transformation
      glMatrixMode( GL_MODELVIEW );
      glLoadIdentity();
      glTranslatef( m_xTransform, m_yTransform, m_zTransform );
      glRotatef( m_xRotation, 1.0f, 0.0f, 0.0f );
      glRotatef( m_yRotation, 0.0f, 1.0f, 0.0f );
      glRotatef( m_zRotation, 0.0f, 0.0f, 1.0f );
}

void BaseCamera::CameraToPoint( float x, float y )
{
    CameraToPoint( x, y, m_zTransform );
}

void BaseCamera::CameraToPoint( float x, float y, float z )
{
    m_xTransform = -x;
    m_yTransform = -(y + 32);
    m_zTransform = z;
}

void BaseCamera::RotX( int multiplier )
{
    m_xRotation += multiplier*m_RotationSpeed;
}

void BaseCamera::RotY( int multiplier )
{
    m_yRotation += multiplier*m_RotationSpeed;
}

void BaseCamera::RotZ( int multiplier )
{
    m_zRotation += multiplier*m_RotationSpeed;
}

void BaseCamera::TransX( int multiplier )
{
    m_xTransform += multiplier*m_TransformSpeed;
}

void BaseCamera::TransY( int multiplier )
{
    m_yTransform += multiplier*m_TransformSpeed;
}

void BaseCamera::TransZ( int multiplier )
{
    m_zTransform += multiplier*m_TransformSpeed;
}


}
